package servlet;

import dao.MajorDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

@WebServlet(value = "/deleteMajorServlet")
public class DeleteMajorServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1. 收集数据
        request.setCharacterEncoding("utf-8");
        String id=request.getParameter("id");
        MajorDao.deleteMajorById(id);
        //3. 选择视图显示结果
        response.sendRedirect("/lab08/showAllMajorsServlet");
    }
}
